<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>children</title>
</head>
<body>
  <div id="app">
    {{message}}
    <cpn></cpn>
    <cpn></cpn>
    <cpn ref="aaa"></cpn>
    <button @click="btnClick">按钮</button>
  </div>

  <template id="cpn">
    <div>我是子组件</div>
  </template>

  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        message: 'yuhao'
      },
      methods: {
        btnClick() {
          console.log(this.$children);
          console.log(this.$refs);
        }
      },
      components: {  //注册组件
        cpn: {
          template: '#cpn',  //绑定模板
          methods: {
            showMessage() {
              console.log('showMessage');
            }
          },
        }
      }
    })
  </script>
</body>
</html>